package com.inspur.edp.common.expr.expresses.array;


import com.inspur.edp.common.expr.Express;
import com.inspur.edp.common.expr.ExpressDSLGenerator;
import com.inspur.edp.common.expr.ExpressDSLGeneratorMgr;
import com.inspur.edp.common.expr.ast.ASTContext;

/**
 * @author lizhaorui
 * @description TODO
 * @date 2024/12/17 10:30
 */
public class ArrayAccessDSL implements ExpressDSLGenerator {

    @Override
    public String getKind() {
        return ArrayAccessExpr.KIND;
    }

    @Override
    public String generate(ASTContext context, Express express) {
        ArrayAccessExpr arrayAccessExpr = (ArrayAccessExpr) express;
        String arrayExpressDsl = ExpressDSLGeneratorMgr.generateDsl(context, arrayAccessExpr.getArrayExpress());
        return String.format("%s[%s]", arrayExpressDsl, arrayAccessExpr.getIndexExpress());
    }

}
